import 'package:flutter/material.dart';

class AnimatedTransactionPage extends StatefulWidget {
  const AnimatedTransactionPage({super.key});

  @override
  _AnimatedTransactionPageState createState() =>
      _AnimatedTransactionPageState();
}

class _AnimatedTransactionPageState extends State<AnimatedTransactionPage>
    with SingleTickerProviderStateMixin {
  late final AnimationController _animtedCtrl =
      AnimationController(vsync: this, duration: Duration(milliseconds: 2000));

  @override
  void dispose() {
    // TODO: implement dispose
    _animtedCtrl.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text('模板'),
        ),
        floatingActionButton: FloatingActionButton(
          onPressed: () {
            _animtedCtrl.repeat(reverse: true);
          },
          child: Icon(Icons.add),
        ),
        body: Column(
          children: [
            SlideTransition(
              // position: _animtedCtrl.drive(
              //   Tween(begin: const Offset(0, 0), end: const Offset(0, 1),),),
              // interval  从什么时间段开始动画 0.8，1 指0.0-0.7 什么事情都不干，0.8开始把动画做完到1.0
              position:
                  Tween(begin: const Offset(0, 0), end: const Offset(0, 1))
                      .chain(CurveTween(curve: Curves.bounceInOut))
                      .animate(_animtedCtrl),
              child: Container(
                width: 100,
                height: 100,
                color: Colors.blue,
              ),
            )
          ],
        ));
  }
}
